home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-16 | 3.3 KB | 117 lines | [TEXT/MPS ] |
- { File: SpiNit.p
- By: Jonathan Gary & Bill Johnson
- Date: 6/15/89
- Purpose: To annoy the user to the max.
- This routine is called by a patch to show window.
- Then we criminally draw a spinning rect into the WMgrPort.
- Inspired by the old time movies and Pythagoreas [sp].
- }
-
-
- UNIT SpuNit;
-
- INTERFACE
-
- USES
- MemTYPEs, QuickDraw, OSIntf, PasLibIntf, ToolIntf, SANE, PackIntf;
-
- PROCEDURE SpinFrame (wPtr: WindowPtr);
-
- IMPLEMENTATION
-
- PROCEDURE SpinFrame (wPtr: WindowPtr);
- CONST
- kAngleStep = 60;
- kAngleOffset = 10;
- kZoomSteps = 4;
- kClipSize = 32000;
-
- { this is wrong, but so what!}
-
- FUNCTION CenterOfRect (theRect: Rect): Point;
-
- BEGIN
- CenterOfRect.h := (theRect.left + (theRect.right - theRect.left) DIV 2);
- CenterOfRect.v := (theRect.top + (theRect.bottom - theRect.top) DIV 2);
- END;
-
- VAR
- oldTop, oldBot, oldLeft, oldRight: integer;
- center: Point;
- wMgrPort, savePort: GrafPtr;
- hSize, vSize, stepVSize, stepHSize, height, width, offset1, offset2, onOff, hh, vv: integer;
- zoomStep, step, loopLimit: integer;
- theta: Real;
- anotherRect, spinRect: Rect;
- saveClip: RgnHandle;
- savePen: PenState;
- finalTick: longint;
- sinArr1, sinArr2, cosArr1, cosArr2: ARRAY[0..12] OF real;
-
- BEGIN
- GetPort(savePort);
- SetPort(wPtr);
- spinRect := wPtr^.portRect;
- LocalToGlobal(spinRect.topLeft);
- LocalToGlobal(spinRect.botRight);
- center := CenterOfRect(spinRect);
- oldTop := spinRect.top;
- oldBot := spinRect.bottom;
- oldLeft := spinRect.left;
- oldRight := spinRect.right;
- hSize := oldRight - oldLeft;
- vSize := oldbot - oldtop;
- loopLimit := 360 DIV kAngleStep;
- GetWMgrPort(wMgrPort);
- SetPort(wMgrPort);
- GetPenState(savePen);
- PenMode(patXor);
- PenSize(2, 2);
- saveClip := NewRgn;
- GetClip(saveClip);
- SetRect(anotherRect, -32000, -32000, 32000, 32000);
- ClipRect(anotherRect);
- { init trig tables -- I know, it's semi - redundant }
- sinArr1[0]:= 0.173648;cosArr1[0]:= 0.984808;sinArr2[0]:= 0.984808;cosArr2[0]:= -0.173648;
- sinArr1[1]:= 0.939692;cosArr1[1]:= 0.342021;sinArr2[1]:= 0.34202;cosArr2[1]:= -0.939693;
- sinArr1[2]:= 0.766044;cosArr1[2]:= -0.642788;sinArr2[2]:= -0.642787;cosArr2[2]:= -0.766045;
- sinArr1[3]:= -0.173649;cosArr1[3]:= -0.984808;sinArr2[3]:= -0.984808;cosArr2[3]:= 0.173648;
- sinArr1[4]:= -0.939693;cosArr1[4]:= -0.34202;sinArr2[4]:= -0.342021;cosArr2[4]:= 0.939692;
- sinArr1[5]:= -0.766044;cosArr1[5]:= 0.642788;sinArr2[5]:= 0.642788;cosArr2[5]:= 0.766044;
- sinArr1[6]:= 0.173648;cosArr1[6]:= 0.984808;sinArr2[6]:= 0.984808;cosArr2[6]:= -0.173649;
-
-
- FOR zoomStep := kZoomSteps DOWNTO 2 DO
- BEGIN
-
-
- FOR step := 0 TO loopLimit - 1 DO
- BEGIN
- width := trunc(sinArr1[step] * (hSize)) div zoomStep;
- height := trunc(cosArr1[step] * (hSize)) div zoomStep;
- hh := trunc(sinArr2[step] * (vSize)) div zoomStep;
- vv := trunc(cosArr2[step] * (vSize)) div zoomStep;
- stepVSize := (-height DIV 2);
- stepHSize := (-width DIV 2);
- FOR onOff := 1 TO 2 DO
- BEGIN
- MoveTo(center.h, center.v);
- Move(stepHSize, stepVSize);
- Line(width, height);
- Line(hh, vv);
- MoveTo(center.h, center.v);
- Move(stepHSize, stepVSize);
- Line(hh, vv);
- Line(width, height);
- Delay(1, finalTick); { cheesey - wait for retrace }
- END;
- END;
- END;
- SetClip(saveClip);
- DisposeRgn(saveClip);
- SetPenState(savePen);
- SetPort(savePort);
- END;
-
-
- END. { of unit }